﻿using Cemit.PolyProto;
using Google.Protobuf;
using Google.Protobuf.WellKnownTypes;
using System;
using System.Collections.Generic;
using System.Text;

namespace Cemit.PolyServer
{
    public class AsyncGetHandle : IMessageHandle<G>
    {
        public void Execute(ClientState clientState, IMessage message)
        {
            G getMsg = this.AsMessage(message);

            IMessage report = getMsg.GetHandle().Execute(getMsg);

            //启动消息处理失败
            if (report == null)
            {
                return;
            }

            this.Log("已发送远程回执：" + getMsg.Index);

            clientState.Send(new V
            {
                Index = getMsg.Index,
                Msg = Any.Pack(report)
            });
        }
    }
}
